package com.example.moonbucks1127;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class LoginActivity extends AppCompatActivity {

    private Button loginButton;
    private Button forgetpasswordButton;
    private EditText usernameEditText;
    private EditText passwordEditText;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);
        findView();
        setListener();
    }
    private void findView(){
        loginButton=findViewById(R.id.btn_loginin);
        usernameEditText=findViewById(R.id.edit_username);
        passwordEditText=findViewById(R.id.edit_password);
        forgetpasswordButton=findViewById(R.id.btn_forgetpassword);
    }

    private void setListener(){
        loginButton.setOnClickListener(new btnLoginClickListener());
    }

    private class btnLoginClickListener implements View.OnClickListener {
        @Override
        public void onClick(View view) {
            if (usernameEditText.getText().length()==0){
                Toast.makeText(LoginActivity.this, "请输入账号", Toast.LENGTH_SHORT).show();
                return;
            }
            if (passwordEditText.getText().length()==0){
                Toast.makeText(LoginActivity.this, "请输入密码", Toast.LENGTH_SHORT).show();
                return;
            }
            startActivity(new Intent(LoginActivity.this,FirstActivity.class));
        }
    }
}
